
class Mythread extends Thread{
    @Override
    public void run() {
        while(true){
            System.out.println("新进程正在运行中");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class demo1 {
    public static void main(String[] args) throws InterruptedException {
//        Thread mythread=new Mythread();
//        mythread.start();
        System.out.println("main主线程运行中");
        Thread t=new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("新线程");
            }
        });
        t.start();

        Thread.sleep(2000);
        t.run();
        Thread.sleep(3000);
        t.join();
        }

}
